
/**
 * AppleIIGo
 * IOU (Input Output Unit) class
 * (C) 2008 by Marc S. Ressl (mressl@umich.edu)
 * Released under the GPL
 */

#include "Motherboard.h"

#ifndef IOU_H
#define IOU_H

typedef enum {
	IOUTYPE_II,
	IOUTYPE_IIJPLUS,
	IOUTYPE_IIE,
	IOUTYPE_IIEENH,
	IOUTYPE_IIC,
	IOUTYPE_IIGS,
};

#define MAPPEDSLOT_NUM	8

#define SLOT_EXTERNAL	0
#define SLOT_INTERNAL	8
#define SLOT_END		16

class IOU : public Device {
public:
	IOU(class Motherboard * motherboard, UINT32 iouType);
	
	void onDevicesConnected();
	void onResetAsserted(bool isRestart);
	
	void writeIo(UINT32 address, UINT8 value);
	UINT8 readIo(UINT32 address);
	
	void setSlot3External(bool value);
	bool isSlot3External();
	void setSlotRegister(UINT8 slotRegister);
	UINT8 getSlotRegister();
	
	void connectAn0ToVideoterm(bool value);
	
private:
	bool isIIjplusIOU;
	bool isIIeIOU;
	bool isIIeEnhancedIOU;
	bool isIIcIOU;
	bool isIIGSIOU;
	
	class CPU * cpu;
	class MMU * mmu;
	class Memory * memory;
	class MIG * mig;
	class TimingGenerator * timingGenerator;
	class VideoRenderer * videoRenderer;
	class Speaker * speaker;
	class Keyboard * keyboard;
	class Paddles * paddles;
	class Mouse * mouse;
	class ADB * adb;
	class DOC * doc;
	class RTC * rtc;
	class SCC * sccA;
	class SCC * sccB;
	
	class SlotDevice * slot[16];
	class SlotDevice * mappedSlot[8];
	class AuxSlotDevice * auxSlot;
	class ChipDevice * chip;
	
	UINT8 ioSlotSel;
	bool isSlot3ExternalValue;
	UINT32 slotRegister;
	
	bool isIIcIOUEN;
	
	bool isAn0ConnectedToVideoterm;
};

#endif
